
  <!-- <ClassifiedSonVue :titleArr="titleArr" :icon="true" :right="false" >
    <ClassifySonVue></ClassifySonVue>
    <ClassifySonVue title="饰品" :goodsList="Arr"></ClassifySonVue>
    <div class="bottom">更多商品持续更新中~</div>
  </ClassifiedSonVue>-->


<template>
  <div>
    <Hand left="true" @back="router.back()" title="分类" :iconbool="false">
      <p v-show="icon">
        <van-icon class="icon" @click="goCar" name="cart" color="white" />
      </p>
    </Hand>
    <div class="box">
      <div class="left">
        <van-sidebar v-model="active" class="leftBox">
          <van-sidebar-item v-for="item in titleArr" :title="item.title" class="leftItem" :key="item.id"
            @click="changeRight(item.title)" />
        </van-sidebar>
      </div>
      <Type>
        <template #right>
          <div class="Li">
            <ClassifySonVue :title="title" :goodsList="Arr"></ClassifySonVue>
            <div class="bottom">更多商品持续更新中~</div>
          </div>
        </template>
      </Type>
    </div>
  </div>
</template>
  
<script setup>
import ClassifySonVue from "./ClassifySon.vue";
import Hand from "../../components/Hand.vue";
import { ref } from "vue";
import { useRouter, useRoute } from "vue-router";
import Type from "../../components/Type.vue";
import { useListStore } from "../../stores/list";
import { useCarStore } from "../../stores/car.js";

const carStore = useCarStore();
const router = useRouter();
const route = useRoute();
const listStore = useListStore();

// if (route.path === "/Classify") {
//   listStore.getInfo();
// }
const active = ref(0);
defineProps({
  icon: {
    type: Boolean,
    default: true
  }
});

function goCar() {
  // router.push("/Car")

  const token = localStorage.getItem("token");




  carStore.getInfo(token).then(() => {
    router.push({
      path: '/Car',
      query: {
        TextTitle: "购物车"
      }
    })
  });




}
const activeName = ref("a");
const title = ref("家居饰品");
const Arr = ref(listStore.Accessories);
function changeRight(t) {
  title.value = t
  if (t === "家居饰品") {
    Arr.value = listStore.Accessories;
  } else if (t === "厨卫用品") {
    Arr.value = listStore.kitchenware;
  } else if (t === "垃圾处理") {
    Arr.value = listStore.Garbage;
  } else if (t === "家用电器") {
    Arr.value = listStore.Appliance;
  }
}
const titleArr = [
  {
    id: 1,
    title: "家居饰品"
  },
  {
    id: 2,
    title: "厨卫用品"
  },
  {
    id: 3,
    title: "垃圾处理"
  },
  {
    id: 4,
    title: "家用电器"
  }
];


router.beforeEach((to, from) => {
  // console.log(to, from)
})
</script>
  
<style lang="less" scoped>
.icon {
  font-size: 6.667vw;
}

.box {
  width: 100vw;
  height: 100vh;
  display: flex;

  .left {
    width: 21.333vw;
    background: #fff;

    .leftBox {
      width: 100%;

      .leftItem {
        background: #fff;
      }

      .leftItem::before {
        height: 80%;
        background-color: #ff5e81;
        border-radius: 3px;
        color: #ff5e81;
        font-weight: 200;
      }

      .leftItem:hover {
        color: #ff5e81;
      }
    }
  }
}

.Li {
  border-radius: 2.667vw;
  padding: 2.667vw;
  background-color: #ffff;
  margin-bottom: 2.667vw;

  span:nth-of-type(1) {
    display: inline-block;
    font-size: 4vw;
    font-weight: 800;
    padding-left: 2.667vw;
    border-left: 0.667vw solid red;
    margin-bottom: 2.667vw;
  }

  .Span {
    padding-left: 3.333vw;
    margin-bottom: 5.667vw;
    font-family: "微软雅黑";
    font-weight: 400;
    font-style: normal;
    font-size: 14px;
    text-align: left;
  }
}

.bottom {
  background: white;
  text-align: center;
  font-size: 3.467vw;
  font-weight: bold;
  color: #cccccc;
  line-height: 13.333vw;
  border-radius: 2.667vw;
}
</style>






